<template>
  <div class="type_area">
    <!-- 头部信息栏 -->
    <div class="header">
      <div class="contener">
        <!-- 栅格布局外部边框四个 -->
        <!-- 响应式手机以及电脑 宽屏四个,直到变成手机变为一个 -->
        <div class="grid">
          <el-row :gutter="20">
            <el-col :xs="24" :lg="6"><div class="grid-content bg-purple red">
              <div class="top">
                <div class="text">
                  推广信息
                </div>
              </div>
              <div class="bottom">
                <!-- 内部栅格布局两个或者三个 -->
                <el-row :gutter="10" style="flex:1;">
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待确认</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>推广中</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待推广</span>
                    </div>
                  </el-col>
                </el-row>
              </div>
            </div></el-col>
            <el-col :xs="24" :lg="6"><div class="grid-content bg-purple blue">
              <div class="top">
                <div class="text">
                  推广信息
                </div>
              </div>
              <div class="bottom">
                <el-row :gutter="10" style="flex:1;">
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待确认</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>推广中</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待推广</span>
                    </div>
                  </el-col>
                </el-row>
              </div>
            </div></el-col>
            <el-col :xs="24" :lg="6"><div class="grid-content bg-purple green">
              <div class="top">
                <div class="text">
                  推广信息
                </div>
              </div>
              <div class="bottom">
                <el-row :gutter="10" style="flex:1;">
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待确认</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>推广中</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待推广</span>
                    </div>
                  </el-col>
                </el-row>
              </div>
            </div></el-col>
            <el-col :xs="24" :lg="6"><div class="grid-content bg-purple orange">
              <div class="top">
                <div class="text">
                  推广信息
                </div>
              </div>
              <div class="bottom">
                <el-row :gutter="10" style="flex:1;">
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待确认</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>推广中</span>
                    </div>
                  </el-col>
                  <el-col :xs="8" :sm="8" :md="8" :lg="8" :xl="8">
                    <div class="grid-content bg-purple">
                      <span>0</span>
                      <span>待推广</span>
                    </div>
                  </el-col>
                </el-row>
              </div>
            </div></el-col>
          </el-row>
        </div>
      </div>
    </div>
    <!-- 底部信息栏 -->
    <div class="footer">
      <el-row :gutter="20">
        <el-col :xs="24" :sm="24" :md="24" :lg="12">
          <div class="chart" style="background:#fff">
            <div id="leftChart" ref="rankLeft" class="chart" />
          </div>
        </el-col>
        <el-col :xs="24" :sm="24" :md="24" :lg="12">
          <div class="chart" style="background:#fff">
            <div id="rightChart" ref="rankRight" class="chart" />
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'Index',
  data() {
    return {
      // 版本号
      version: '3.8.4',
      main_div_w: 0,
      main_div_h: 0
    }
  },
  mounted() {
    // 左边的响应式echarts图表
    setTimeout(() => {
      this.leftCharts()
      const resizeOb = new ResizeObserver((entries) => {
        for (const entry of entries) {
          echarts.getInstanceByDom(entry.target).resize()
        }
      })
      resizeOb.observe(this.$refs.rankLeft)
    })
    // 右边边的响应式echarts图表
    setTimeout(() => {
      this.rightCharts()
      const resizeOb = new ResizeObserver((entries) => {
        for (const entry of entries) {
          echarts.getInstanceByDom(entry.target).resize()
        }
      })
      resizeOb.observe(this.$refs.rankRight)
    })
  },
  methods: {
    goTarget(href) {
      window.open(href, '_blank')
    },
    // 左侧图标结构样式
    leftCharts() {
      const myChart = echarts.init(this.$refs.rankLeft)
      const option = {
        title: {
          text: '数据'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        legend: {
          data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: 'Email',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: 'Union Ads',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [220, 182, 191, 234, 290, 330, 310]
          },
          {
            name: 'Video Ads',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [150, 232, 201, 154, 190, 330, 410]
          },
          {
            name: 'Direct',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [320, 332, 301, 334, 390, 330, 320]
          },
          {
            name: 'Search Engine',
            type: 'line',
            stack: 'Total',
            label: {
              show: true,
              position: 'top'
            },
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [820, 932, 901, 934, 1290, 1330, 1320]
          }
        ]
      }
      myChart.setOption(option)
    },
    // 右侧图标结构样式
    rightCharts() {
      const myChart = echarts.init(this.$refs.rankRight)
      const option = {
        title: {
          text: '数据'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        legend: {
          data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: 'Email',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: 'Union Ads',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [220, 182, 191, 234, 290, 330, 310]
          },
          {
            name: 'Video Ads',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [150, 232, 201, 154, 190, 330, 410]
          },
          {
            name: 'Direct',
            type: 'line',
            stack: 'Total',
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [320, 332, 301, 334, 390, 330, 320]
          },
          {
            name: 'Search Engine',
            type: 'line',
            stack: 'Total',
            label: {
              show: true,
              position: 'top'
            },
            areaStyle: {},
            emphasis: {
              focus: 'series'
            },
            data: [820, 932, 901, 934, 1290, 1330, 1320]
          }
        ]
      }
      myChart.setOption(option)
    }
  }
}

// 绘制图表

</script>

<style lang="scss" scoped>
.app-main {
  /* 50= navbar  50  */
  min-height: calc(100vh - 100px);
  width: 100%;
  position: relative;
  overflow: hidden;
}

.fixed-header + .app-main {
  padding-top: 50px;
}

.hasTagsView {
  .app-main {
    /* 84 = navbar + tags-view = 50 + 34 */
    min-height: calc(100vh - 84px);
    background-color: #f0f2f5;
  }

  .fixed-header + .app-main {
    padding-top: 84px;
  }
}
// fix css style bug in open el-dialog
.el-popup-parent--hidden {
  .fixed-header {
    padding-right: 17px;
  }
}
.type_area{
  padding: 32px;
}
.header{
  width: 100%;
  min-height: 142px;
}
.contener{
  display: flex;
  justify-content: space-between;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tofix{
  display: flex;
  justify-content: space-evenly;
  width: 100%;
}
// 栅格布局
.el-col {
    border-radius: 4px;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  // 四种颜色栅格布局
.red{
  height: 120px;
  width: 100%;
  background: linear-gradient(135deg,#3789ff,#78f56a);
}
.blue{
  height: 120px;
  width: 100%;
  background: linear-gradient(135deg,#225ffb,#01bbff);
}
.green{
  height: 120px;
  width: 100%;
  background: linear-gradient(135deg,#00ce98,#00db7d);
}
.orange{
  height: 120px;
  width: 100%;
  background: linear-gradient(135deg,#f37b5c,#f57878);
}
.top{
  height: 43px;
  width: 41.6666666667%;
  text-align: center;
  color:#fff;
  font-size: 14px;
  display: flex;
  justify-content: center;
}
.text{
  box-sizing: border-box;
  padding: 15px 6px 6px;
  width: 68px;
  border-bottom:2px solid #fff ;
  height: 43px;
}
.bottom{
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-left: 20px;
  padding: 20px 20px 0px 6px;
}
.bottom span{
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 14px;
  color: #fff;
}
.grid{
  width: 100%;
  margin-bottom: 10px;
}
.bg-purple{
  margin-bottom: 10px;
}
.footer{
  width: 100%;
}
.chart{
  width: 100%;
  height: 300px;
  background-color: #fff;
  padding: 0 8px;
  margin-bottom: 20px;
}

</style>
